from imageai.Detection import ObjectDetection
import os
import time

def main():
    execution_path = os.getcwd()
    print(execution_path)
    detector = ObjectDetection()
    detector.setModelTypeAsYOLOv3()
    detector.setModelPath(os.path.join("./cfg/yolo.h5"))
    # detector.setModelPath(os.path.join("./cfg/head.h5"))
    detector.loadModel()
    val1 = time.time()
    detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path, "100.png"),
                                                 output_image_path=os.path.join(execution_path,  "1.png"))
    val2 = time.time()
    print(val2-val1)
    for eachObject in detections:
        print(eachObject["name"], " : ", eachObject["percentage_probability"], " : ", eachObject["box_points"])


if __name__ == "__main__":
    main()

